package com.ruoyi.web.controller.travel;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.travel.domain.TravelScheduleContent;
import com.ruoyi.travel.service.ITravelScheduleContentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

@RestController
@RequestMapping("/travel/schedule/content")
public class TravelScheduleContentController extends BaseController
{
    @Autowired
    private ITravelScheduleContentService travelScheduleContentService;

    /**
     * 查询行程内容列表
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:list')")
    @GetMapping("/list")
    public TableDataInfo list(TravelScheduleContent travelScheduleContent)
    {
        startPage();
        List<TravelScheduleContent> list = travelScheduleContentService.selectTravelScheduleContentList(travelScheduleContent);
        return getDataTable(list);
    }


    /**
     * 获取行程内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:query')")
    @GetMapping(value = "/{scheduleContentId}")
    public AjaxResult getInfo(@PathVariable("scheduleContentId") Long scheduleContentId)
    {
        return success(travelScheduleContentService.selectTravelScheduleContentByScheduleContentId(scheduleContentId));
    }

    /**
     * 新增行程内容
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:add')")
    @Log(title = "行程内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<TravelScheduleContent> travelScheduleContent)
    {
        travelScheduleContentService.insertTravelScheduleContent(travelScheduleContent);
        return AjaxResult.success();
    }

    /**
     * 修改行程内容
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:edit')")
    @Log(title = "行程内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelScheduleContent travelScheduleContent)
    {
        return toAjax(travelScheduleContentService.updateTravelScheduleContent(travelScheduleContent));
    }

    /**
     * 删除行程内容
     */
    @PreAuthorize("@ss.hasPermi('travel:schedule:remove')")
    @Log(title = "行程内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scheduleId}")
    public AjaxResult remove(@PathVariable Long scheduleId)
    {
        return toAjax(travelScheduleContentService.deleteTravelScheduleContentByScheduleId(scheduleId));
    }
}
